!{include file='common/iheader.htm'}
<style>
	.list_view strong{width:65%}
	.list_view span{color:#999;}
	.opt_div{width:34%}
	.form_btn_item{margin-top:20px;}
	#temp_dir{display:none}
	.form_item strong{width:60px;}
</style>
<div id="i_nav">
	<h3 class="page_title">关联属性管理</h3>
	<a class="button" href="/manager.php?app=attrs">属性组管理</a>
	<a class="button" href="javascript:void(0)" onclick="edit()">添加关联属性</a>
	<a class="button" href="/manager.php?app=forms">表单管理</a>
</div>
<ul class="list_view">
	!{foreach from=$relations item=relation key=id}
	<li id="relation_!{$id}">
		<strong>
			[!{$relation.code}] <a href="javascript:void(0)" onclick="edit('!{$id}')" title="!{$relation.desc}">!{$relation.$site_lang.name}</a>
			!{if $relation.$site_lang.desc}
			<span class="ui-icon ui-icon-info" title="!{$relation.$site_lang.desc}"></span>
			!{/if}
		</strong>
		<div class="opt_div">
			<a href="javascript:void(0)" onclick="edit('!{$id}')"><span class="ui-icon ui-icon-pencil"></span>修改</a>
			<a href="javascript:void(0)" onclick="del('!{$id}')"><span class="ui-icon ui-icon-trash"></span>删除</a>
		</div>
	</li>
	!{foreachelse}
	<li>
		<strong>暂无记录...</strong>
	</li>
	!{/foreach}
</ul>
<div class="dialog" id="relation_edit" title="关联属性编辑"></div>
<div class="dialog" id="relation_item_edit" title="属性条目编辑"></div>
<script type="text/javascript">
	function del(id){
		if(confirm('删除后，将可能影响使用，是否继续删除？')){
			var url = '/manager.php?app=relation&act=del&id=' + id;
			$.get(url, function(data){
				var json = eval('(' + data + ')');
				alert(json.info);
				if(json.result){
					$("#relation_" + id).remove();
				}
			});
		}
	}

	function del_item(id, rid){
		if(confirm('删除后，将可能影响使用，是否继续删除？')){
			var url = '/manager.php?app=relation&act=del_item&id=' + id + "&rid=" + rid;
			$.get(url, function(data){
				var json = eval('(' + data + ')');
				alert(json.info);
				if(json.result){
					$("#rid_" + rid).remove();
				}
			});
		}
	}

	function edit(id){
		var url = '/manager.php?app=relation&act=edit';
		if(id!=null){
			url += '&id=' + id;
		}
		$('#relation_edit').html('正在加载...');
		$('#relation_edit').dialog({
			modal : true,
			width:560,
			height:400,
			open : function(){
				$('#relation_edit').load(url);
			}
		});
	}
	
	function edit_item(id, rid){
		var url = '/manager.php?app=relation&act=item_edit&id=' + id;
		if(rid != null){
			url += '&rid=' + rid;
		}
		$('#relation_item_edit').dialog({
			width:550,
			height:340,
			modal : true,
			open : function(){
				$('#relation_item_edit').html('正在加载...').load(url);
				return;
				$('#new_item_form').ajax_form({
					'submit_btn' : '.submit',
					'success' : function(){
						window.location.href = '/manager.php?app=attrs&act=relation';
					}
				});
			}
		});
	}
</script>
!{include file='common/ifooter.htm'}